package dbLayer;

import java.sql.SQLException;
import java.util.List;

import modelLayer.Teacher;
import modelLayer.TeachingBlock;
import modelLayer.Subject;
import modelLayer.ClassRoom;
import modelLayer.Class;

/**
 * This class is a part of the MSAS system. It declares methods in order to insert, 
 * retrieve, update and delete information about teaching-blocks in a database.
 * 
 @author   Danny M. Pedersen,
 * 		   Anna Kelemen,
 * 		   Jakob Korsgaard
 * @version 1.3
 * 			1.3.2: getAllByClass() and removeByClassAndSubject() added, (design class diagram updated)
 */
public interface DBTeachingBlockIF {

	/**
	 * Inserts information about a teachingblock in the database.
	 * Takes the objects which are associated to a teaching-block as parameters.
	 * 
	 * @param 		cl		Class		an instance of Class associated to a teachingblock
	 * @param 		s		Subject	 	an instance of Subject associated to a teachingblock
	 * @param 		cr		ClassRoom	an instance of ClassRoom associated to a teachingblock
	 * @param 		name	String		the name of the teachingblock
	 * @return 		rc		int			the count of rows changed in the database
	 * @throws 				Exception
	 */
	public int insert(Class cl, Subject s, ClassRoom cr, Teacher t, String name) throws SQLException;
	
	/**
	 * Finds a row in the database table TeachingBlock.
	 * 
	 * @param 		name				String		the name of the teachingblock
	 * @param 		retrieveAssociation	boolean		determines if we're to retrieve additional information
	 * 												on the teachingblock
	 * @return 							TeachingBlock
	 */
	public TeachingBlock find(String name, boolean retrieveAssociation);
	
	/**
	 * Finds a row in the database table TeachingBlock.
	 * 
	 * @param 		id					int			the id of the teachingblock
	 * @param 		retrieveAssociation	boolean		determines if we're to retrieve additional information
	 * 												on the teachingblock
	 * @return 							TeachingBlock
	 */
	public TeachingBlock findById(int id, boolean retrieveAssociation);
	
	
	/**
	 * Finds all the rows in the database table Teaching block, where the class id equals the methods parameter.
	 * 
	 * @param classId
	 * @param retrieveAssociation
	 * @return 	a list of matching teachingblocks
	 */
	public List<TeachingBlock> getAllByClass(int classId, boolean retrieveAssociation);
	
	/**
	 * Returns all rows in the database table TeachingBlock.
	 * 
	 * @param 		retrieveAssociation	boolean 			determines if we're to retrieve additional information
	 * 														on the teachingblock
	 * @return 							List<TeachingBlock>	a collection of TeachingBlocks
	 */
	public List<TeachingBlock> getAll(boolean retrieveAssociation);
	
	/**
	 * Updates a row in the database table TeachingBlock.
	 * 
	 * @param 	tb 	TeachingBlock	an instance of TeachingBlock
	 * @return 	rc	int				the count of rows changed in the database
	 */
	public int update(TeachingBlock tb) throws SQLException;
	
	/**
	 * Removes a row in the database table TeachingBlock.
	 * 
	 * @param 	id 	int		the id of the teachingblock
	 * @return 	rc	int 	the count of rows changed in the database.
	 */
	public int remove(int id);
	
	/**
	 * Removes the rows in the database table TeachingBlock where the class and subject equals the parameters.
	 * 
	 * @param classId
	 * @param subjectId
	 * @return rc	int 	the count of rows changed in the database.
	 */
	public int removeByClassAndSubject(int classId, int subjectId);

	
}
